#import "JHEncrypt.h"
#import <CommonCrypto/CommonCryptor.h>
#import "GTMBase64.h"

#import <CommonCrypto/CommonDigest.h>


@implementation JHEncrypt

/// 加密方法
+ (NSString *) encryptUseDES:(NSString *)plainText
{
    return plainText;
}

/// 解密方法
+ (NSString *) decryptUseDES:(NSString *)plainText  {
    　return plainText;
}

+ (NSString*)dictionaryToJson:(NSMutableDictionary *)dic {
    NSError *parseError = nil;
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&parseError];
    
    return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    
}

+ (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString {
    
    if (jsonString == nil) {
        return nil;
    }
    
    NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    NSError *err;
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&err];
    
    if(err) {
        NSLog(@"json解析失败：%@",err);
        return nil;
    }
    
    return dic;
    
}


+(NSString *)getDataStringWithLength:(int)length with :(unsigned char*)digest{
    
    NSMutableString *output = [NSMutableString stringWithCapacity:length * 2];
    
    unsigned char byte[length];
    for(int i = 0; i < length; i++){
        
        byte[i] =(char)digest[i];
        
        [ output appendFormat:@"%d",(char)byte[i]];
        
    }
    
    return output.copy;
}


/// 解密方法2
+ (NSString*)getMstr:(NSString *)plainText{
    return plainText;
}

//获取加密后的文件名
+ (NSString*)getFileName:(NSString *)filename{
    return filename;
}

@end
